package com.presto.directo.utils

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri

fun Context.getAppVersion(): String {
    return try {
        packageManager.getPackageInfo(packageName, 0).versionName
    } catch (e: Exception) {
        ""
    }
}

fun Activity.toPlay(pkg: String = packageName) {
    val play = "com.android.vending"
    try {
        val uri = Uri.parse("market://details?id=$pkg")
        val intent = Intent(Intent.ACTION_VIEW, uri)
        intent.setPackage(play)
        startActivity(intent)
    } catch (e: Exception) {
    }
}